import { createRouter, createWebHashHistory} from 'vue-router'
import routes from './routes'

const router = createRouter({
  history: createWebHashHistory(),
  routes
})
// 导航守卫
router.beforeEach((to, from) => {
  if (to.path === '/login') return true
  const token = sessionStorage.getItem('token')
  if (!token) {
    return { path: '/login' }
  }
  return true
})

export default router
